﻿using SharpDX;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace WpfModelEditor.Core.Converters
{
    public class Color4Convert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (Color4)value;
            return System.Windows.Media.Color.FromScRgb(v.Alpha, v.Red, v.Green, v.Blue);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (System.Windows.Media.Color)value;
            return new Color4(v.R / 255f, v.G / 255f, v.B / 255f, v.A / 255f);
        }
    }
    public class Color4BrushConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (Color4)value;
            return new SolidColorBrush(System.Windows.Media.Color.FromScRgb(v.Alpha, v.Red, v.Green, v.Blue));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (System.Windows.Media.SolidColorBrush)value;
            return new Color4(v.Color.R / 255f, v.Color.G / 255f, v.Color.B / 255f, v.Color.A / 255f);
        }
    }
}
